package com.pro.framework.api.enums;

import com.pro.framework.api.util.inner.TimeDifference;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.function.Function;

@Schema(description = "时间单位")
@Getter
@AllArgsConstructor
public enum EnumTimeUnit implements IEnumStr {

    YEAR("年","年", "y", 31_536_000L, null),   // 365天
    QUARTER("季","季", "q", 7_776_000L, null),     // 90天
    MONTH("月","月", "M", 2_592_000L, null),   // 30天
    DAY("日","天", "d", 86_400L, TimeDifference::getDays),
    HOUR("时","小时", "h", 3_600L, TimeDifference::getHours),
    MINUTE("分","分", "m", 60L, TimeDifference::getMinutes),
    SECOND("秒","秒", "s", 1L, TimeDifference::getSeconds),
    ;

    @Schema(description = "单位名称")
    private final String label;

    @Schema(description = "单位名称")
    private final String numLabel;

    @Schema(description = "单位符号")
    private final String symbol;

    @Schema(description = "该单位等于多少秒")
    private final long inSeconds;

    @Schema(description = "该单位等于多少秒")
    private final Function<TimeDifference, Long> propInDiff;
}
